package com.ktgj.sms.api.factory;

import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.sms.api.RemoteSmsService;
import com.ktgj.sms.api.domain.Sms;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 短信服务降级处理
 * 
 * @author ruoyi
 */
@Component
public class RemoteSmsFallbackFactory implements FallbackFactory<RemoteSmsService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteSmsFallbackFactory.class);

    @Override
    public RemoteSmsService create(Throwable cause)
    {
        log.error("短信服务调用失败:{}", cause.getMessage());
        return new RemoteSmsService()
        {
            @Override
            public boolean addSms(Sms sms) {
                log.error("调用短信失败:{}",cause.getMessage());
                return false;
            }

            @Override
            public boolean sendSmsMessage(Sms sms) {
                log.error("调用短信失败:{}",cause.getMessage());
                return false;
            }
        };
    }
}
